import tensorflow as tf

def a():
    a = tf.Variable(initial_value=1.0, dtype=tf.float32)
    b = tf.assign(a, tf.constant(1.0))

    sess = tf.Session()
    sess.run(tf.global_variables_initializer())
    sess.run(b)

def b():
    x = tf.Variable(1.0)
    y = tf.Variable(0.0)
    x_plus_1 = tf.assign_add(x, 1)
    with tf.control_dependencies([x_plus_1]):
        #y = x # wrong use
        y = tf.identity(x)
    init = tf.global_variables_initializer()
    with tf.Session()  as sess:
        sess.run(init)
        for i in range(5):
            print(sess.run([y, x]))
b()